<div class="content-wrapper">
    <section class="content-header">
        <h1>报价列表</h1>
        <ol class="breadcrumb">
            <li><a href="/"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">系统配置</li>
            <li class="active">报价列表</li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-header with-border">
                <form class="form-inline" action="/quoted/quotedList" method="get">
                    <div class="form-group">
                        <label for="resource">资源 </label>
                        <input type="text" class="form-control" id="resource" name="resource" placeholder="资源" value="{$resource}">
                    </div>
                    <div class="form-group">
                        <label class="label-control" for="platform">平台 </label>
                        <input type="text" class="form-control" id="platform" name="platform" placeholder="平台" value="{$platform}">
                    </div>
                    <div class="form-group">
                        <label class="label-control" for="put_target">投放吧 </label>
                        <input type="text" class="form-control" id="put_target" name="put_target" placeholder="投放吧" value="{$put_target}">
                    </div>
                    <button type="submit" class="btn btn-info" id="save-btn">查询</button>
                    <a class="btn btn-primary" href="/Public/tpl/quoted.xls" target="_blank">下载模板</a>
                    <input id='upload' name="file_upload" type="button" value='上传' class='btn btn-large btn-primary'>
                </form>
            </div>
            <div class="box-body table-responsive">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <th style="width: 80px">ID</th>
                        <th>资源</th>
                        <th>投放平台</th>
                        <th>投放位置</th>
                        <th>投放目标-吧</th>
                        <th>PV/天</th>
                        <th>CPM</th>
                        <th>单价</th>
                        <th>起投时间</th>
                        <th>投放天数</th>
                        <th>总价</th>
                        <th style="width: 100px">操作</th>
                    </tr>
                    <if condition="count($quotedList) eq 0"><tr><td class="text-center" colspan="12">暂无数据...</td></tr></if>
                    <foreach name="quotedList" item="quoted">
                        <tr>
                            <td>{$quoted.id}</td>
                            <td>{$quoted.resource}</td>
                            <td>{$quoted.platform}</td>
                            <td>{$quoted.place}</td>
                            <td>{$quoted.put_target}</td>
                            <td>{$quoted.pv}</td>
                            <td>{$quoted.cpm}</td>
                            <td>{$quoted.price}</td>
                            <td>{$quoted.put_time|date='Y-m-d',###}</td>
                            <td>{$quoted.put_day}</td>
                            <td>{$quoted.total_price}</td>
                            <td>
                                <button class="btn btn-primary btn-xs" type="button" onclick="window.location.href='/quoted/editQuoted?id={$quoted.id}'">详情</button>&nbsp;
                                <button class="btn bg-maroon btn-xs btn-delete" type="button" data-id="{$quoted.id}">删除</button>&nbsp;
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
            <div class="box-footer clearfix">{$page_html}</div>
        </div>
    </section>
</div>
<script src="__PUBLIC__/global/AjaxUpload.js"></script>
<script src="__PUBLIC__/AdminLTE/plugins/layer/layer.js"></script>
<script>
    //异步上传文件
    new AjaxUpload("#upload", {
        action: '/admin/quoted/ajaxSaveImport',
        type:"POST",
        name:'import',
        responseType: 'json',
        onSubmit: function(file, ext) {
            if("xls,xlsx".indexOf(ext)<0){
                layer.msg("请上传xls/xlsx格式的文件");
                return false;
            }
            layer.load(1, {
                shade: [0.48,'#999'] //0.1透明度的白色背景
            });
        },
        onComplete: function(file, response) {
            layer.closeAll('loading');
            if(response.Code ==999) {
                layer.msg('上传成功');
                window.location.reload(true);
            }else{
                layer.msg(response.Msg);
                return false;
            }
        }
    });
</script>

<script type="application/javascript">
    $('.btn-delete').click(function () {
        var id = $(this).attr('data-id');
        ArtDialogHlp.showConfirm('提示',"确认删除该数据吗",function () {
            $.post('/admin/quoted/ajaxDeleteQuoted',
                {
                    id : id,
                }, function(data){
                    if(data.Code == 999) {
                        ArtDialogHlp.showInfo('提示', '操作成功', function(){
                            window.location.href = '/admin/quoted/quotedList';
                        });
                    } else {
                        ArtDialogHlp.showInfo('提示', data.Msg);
                    }
                }, 'json');
        });
    });
</script>